-
Notifications
You must be signed in to change notification settings - Fork 275
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix lint #1529
Fix lint #1529
Conversation
It seems you will need to pull this branch and run |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for this.
i think we will need to discuss this offline.
I have some concerns. Mainly, why update .pylintrc?
# paths. | ||
# | ||
# Files under alembic are generated and are nonconforming. | ||
ignore=alembic |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why get rid of stuff like this?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This pylintrc
was generated automatically with the latest version of pylint
, I am working on manually merging our old settings back so that we can have:
- The default settings of the latest
pylint
- The same setting from us in the past.
.pylintrc
Outdated
jobs=0 | ||
# number of processors available to use, and will cap the count on Windows to | ||
# avoid hangs. | ||
jobs=1 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No we don't care about windows.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Most changes ok to land whenever (as long as CI passes without the .pylintrc change)
import numpy as np | ||
import Orange | ||
import seaborn as sns | ||
|
||
from matplotlib import colors |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Did google's styleguide get rid of alphabetical order imports? It looks like it might have.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yep, I remember pylint
specifically requested me to put this at the top (which also surprised me), because it is an external import.
@@ -122,15 +122,15 @@ def measure_loop(experiment: str, | |||
set_up_coverage_binaries(pool, experiment) | |||
# Using Multiprocessing.Queue will fail with a complaint about | |||
# inheriting queue. | |||
q = manager.Queue() # pytype: disable=attribute-error | |||
manager_queue = manager.Queue() # pytype: disable=attribute-error |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
call this multiprocessing_queue
@@ -13,8 +13,6 @@ | |||
# limitations under the License. | |||
"""Tests for run_crashes.py.""" | |||
|
|||
# pylint: disable=no-self-use |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We may need to keep these for now until we update pylintrc
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for this. i think we will need to discuss this offline. I have some concerns. Mainly, why update .pylintrc?
I updated .pylintrc
mainly because I updated pylint
, which is because we updated python
.
This .pylintrc
is automatically generated with the latest version of pylint
, which I presume contains many new settings (e.g., some default settings may have been changed to optional).
I am also working on manually merging some of our old changes to here, e.g. ignore=alembic
Happy to discuss more on this, as I am not certain which settings should be kept.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just come across another reason to update .pylintrc
: I found 35 deprecated and 5 unknown pylint
messages in our old .pylintrc
that cause errors with the new pylint
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I updated .pylintrc mainly because I updated pylint, which is because we updated python.
I think (not sure) this isn't the first time we've upgraded pylint, we usually don't regenerate the entire file.
This .pylintrc is automatically generated with the latest version of pylint, which I presume contains many new settings (e.g., some default settings may have been changed to optional).
I think if we can get away without changing pylintrc now we should, the lint upgrade is incidental, to upgrading python, so it's fine if it's minimal. We can worry about being consistent later.
Merged our old |
No i think we need to fix these :-( |
Sounds like another TODO for me today 🔖 |
@@ -42,6 +42,7 @@ def recreate_directory(directory, create_parents=True): | |||
|
|||
def write(path, contents, open_flags='w'): | |||
"""Opens file at |path| with |open_flags| and writes |contents| to it.""" | |||
# pylint: disable=unspecified-encoding | |||
with open(path, open_flags) as file_handle: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not sure if there is a better way to fix this:
We cannot simply add encoding='utf-8'
as the path
can be a binary file.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this function is probably a bad idea, maybe just get rid of it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
OK, I left a todo on it for another PR as it is involved in several other functions.
# Matches UBSan features enabled in OSS-Fuzz. | ||
# See https://github.com/google/oss-fuzz/blob/master/infra/base-images/base-builder/Dockerfile#L94 | ||
# Matches UBSan features enabled in OSS-Fuzz. See | ||
# https://github.com/google/oss-fuzz/blob/master/infra/base-images/base-builder/Dockerfile#L94 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
.pylintrc
can ignore long URL lines, but its regex pattern needs the line to start with http
/https
.
Would you prefer me to fix this error like this (i.e., forcing long URL lines in code to follow the existing pattern in pylintrc
), or change the pattern in .pylintrc
(e.g., ignore all lines that contain a URL like the old version)?
I reckon all errors from |
@jonathanmetzman: I reckon this is ready to be merged into #1526, please let me know what you think : ) |
Why not merge it here? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM thanks
.github/workflows/fuzzers.yml
Outdated
- aflpp_random_no_favs | ||
- aflpp_random_wrs | ||
- aflcc | ||
- aflpp_random_wrs_rf_rp |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Don't add these please, I think it's breaking CI. Remove them please. CI will fail but that's fine IMO
@@ -42,6 +42,7 @@ def recreate_directory(directory, create_parents=True): | |||
|
|||
def write(path, contents, open_flags='w'): | |||
"""Opens file at |path| with |open_flags| and writes |contents| to it.""" | |||
# pylint: disable=unspecified-encoding | |||
with open(path, open_flags) as file_handle: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this function is probably a bad idea, maybe just get rid of it.
@@ -145,8 +147,8 @@ def measure_loop(experiment: str, | |||
logger.info('Finished measure loop.') | |||
|
|||
|
|||
def measure_all_trials(experiment: str, max_total_time: int, pool, q, | |||
region_coverage) -> bool: # pylint: disable=invalid-name | |||
def measure_all_trials(experiment: str, max_total_time: int, pool, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you remove this pylint directive?
continue | ||
member_file_handle = tar.extractfile(member) | ||
if not member_file_handle: | ||
logger.info('Failed to get handle to %s', member) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit end thsi with a period.
@@ -94,7 +94,8 @@ def eclipser(input_corpus, output_corpus, target_binary): | |||
if os.listdir(input_corpus): # Specify inputs only if any seed exists. | |||
command += ['-i', input_corpus] | |||
print('[eclipser] Run Eclipser with command: ' + ' '.join(command)) | |||
subprocess.Popen(command) | |||
with subprocess.Popen(command): | |||
pass |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you disable this warning just for Popen? If you can let's just do this in .pylintrc (this is kind of burdensome for files in fuzzers/)
fuzzers/gramatron/fuzzer.py
Outdated
@@ -52,7 +52,7 @@ def build(): # pylint: disable=too-many-branches,too-many-statements | |||
raise RuntimeError('Unsupported benchmark, unavailable grammar') | |||
dest = os.path.join(os.environ['OUT'], 'grammar.json.gz') | |||
shutil.copy(copy_file, dest) | |||
os.system("gzip -d '%s'" % dest) | |||
os.system(f"gzip -d '{dest}'") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: single quotes on outside.
.pylintrc
Outdated
known-third-party=enchant | ||
# This flag controls whether inconsistent-quotes generates a warning when the | ||
# character used as a quote delimiter is used inconsistently within a module. | ||
check-quote-consistency=no |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What if you change this to "yes"
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It finds 299 new errors, 272 of which are from different fuzzers' fuzzer.py
: )
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ACtually, don't land this without removing those fuzzers from CI please.
btw I think CI builds still won't run after you undo your additions, it's because of #1536 that it's failing right now. |
OK, I've reverted the commit. |
I am wondering about that, too. |
I think if you pull CI will run again |
Thanks! It looks alright now. |
And by the way, why would the fuzzers in #1537 disable all CI build checks? |
Github must have some limit that we run into silently 🤦 |
@jonathanmetzman : Shall I merge this back to the base branch? Thanks! |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
lgtm
sure! |
Based on and required by #1526.
This PR fixes new lint errors from the latest
pylint
, which is required as #1526 upgradesPython
to3.10
.I reckon I have fixed all meaningful errors in the
FuzzBench
framework, not sure if the rest is worth fixing or could be ignored.The rest lint errors are:
fuzzers/*
);database/*
);df
doesn't conform to snake_case naming style, but is common forpandas.dataframe
).Too few public methods
).Using the global statement
.Consider using 'with' for resource-allocating operations
, e.g., withPopen
,urlopen
.Using open without explicitly specifying an encoding
, e.g., when opening a binary file.Could you please take a look at the rest errors and let me know which one is worth fixing?
Otherwise, I will find a way to let pylint ignore them in the future.